package com.ruoyi.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.Friend;
import com.ruoyi.domain.Notice;
import com.ruoyi.service.NoticeService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Resource
    private NoticeService noticeService;


    @PostMapping("/page")
    public AjaxResult getNotice(@RequestBody Page<Notice> page, @RequestBody Notice notice) {
        noticeService.page(page,new LambdaQueryWrapper<Notice>()
                .eq(Notice::getNoticeUserId, SecurityUtils.getUserId())
        );
        page.setTotal(noticeService.count(new LambdaQueryWrapper<Notice>()
                .eq(Notice::getNoticeUserId, SecurityUtils.getUserId())
        ));
        //返回结果
        return AjaxResult.success(page);
    }






}
